package com.leyou.item.pojo.api;

import com.leyou.common.pojo.PageResult;
import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.Spu;
import com.leyou.item.pojo.SpuBo;
import com.leyou.item.pojo.SpuDetail;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * *
 * Created by IntelliJ IDEA.
 * Author: caoLei
 * Date: 2018/10/29
 * Time: 9:15
 * *
 */
public interface GoodsApi {
    /**
     * 根据关键字分页查询spu
     *
     * @param key
     * @param saleable
     * @param page
     * @param rows
     * @return
     */
    //key=&saleable=true&page=1&rows=5
    @GetMapping("spu/page")
    public PageResult<SpuBo> querySpuByPage(//pageresult在common里面所以，还要引入leyou-common的依赖
                                                            @RequestParam(value = "key", required = false) String key,
                                                            @RequestParam(value = "saleable", defaultValue = "true") Boolean saleable,
                                                            @RequestParam(value = "page", defaultValue = "1") Integer page,
                                                            @RequestParam(value = "rows", defaultValue = "5") Integer rows
    );

    /**
     * 根据spuid查询spuDetail
     *
     * @param spuId
     * @return
     */
    @GetMapping("/spu/detail/{spuId}")
    public SpuDetail querySpuDetailById(@PathVariable("spuId") Long spuId);

    /**
     * 根据spuID查询所有sku
     *
     * @param id
     * @return
     */
    @GetMapping("sku/list")
    public List<Sku> querySkusBySpuId(@RequestParam("id") Long id);

    /**
     * 根据spuId查询spu
     * @param spuId
     * @return
     */
    @GetMapping("spu/{spuId}")
    public Spu querySpuBySpuId(@PathVariable("spuId") Long spuId);

    /**
     * 根据skuid查询sku
     * @param
     * @return
     */
    @GetMapping("sku/{skuId}")
    public Sku querySkuById(@PathVariable("skuId") Long skuId);
}
